package daoimpl;

import dao.DetailDao;
import javabean.Detail;
import util.JDBCUtil;

import java.util.ArrayList;

/**
 * packageName com.mt.bms.daoimpl
 *
 * @author Administrator
 * @version 1.0
 * @className DetailDaoImpl (此处以class为例)
 * @date 2024/8/2
 * @description
 */
public class DetailDaoImpl implements DetailDao<Detail> {
    @Override
    public ArrayList<Detail> selectByMyUsername(String userName) {
        String sql = "select * from detail where myUsername = ? or toUsername = ?";
        return JDBCUtil.dql(sql, Detail.class, userName, userName);
    }

    @Override
    public int insert(Detail detail) {
        String sql = "insert into detail (myUsername, toUsername, money, time) values (?, ?, ?, now())";
        return JDBCUtil.dml(sql, detail.getMyUsername(), detail.getToUsername(), detail.getMoney());
    }

}